home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / TEST / GLUT / TEST1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  2.4 KB  |  92 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <GL/glut.h>
  11.  
  12. char *fake_argv[] =
  13. {
  14.   "program",
  15.   "-display",
  16.   ":0",
  17.   "-geometry",
  18.   "500x400-34-23",
  19.   "-indirect",
  20.   "-iconic",
  21.   NULL};
  22.  
  23. int fake_argc = sizeof(fake_argv) / sizeof(char *) - 1;
  24.  
  25. int
  26. main(int argc, char **argv)
  27. {
  28.   char *altdisplay;
  29.   int screen_width, screen_height;
  30.   int got;
  31.  
  32.   altdisplay = getenv("GLUT_TEST_ALT_DISPLAY");
  33.   if (altdisplay) {
  34.     fake_argv[2] = altdisplay;
  35.   }
  36.   glutInit(&fake_argc, fake_argv);
  37.   if (fake_argc != 1) {
  38.     printf("FAIL: argument processing\n");
  39.     exit(1);
  40.   }
  41.   if ((got = glutGet(GLUT_INIT_WINDOW_WIDTH)) != 500) {
  42.     printf("FAIL: width wrong, got %d, not 500\n", got);
  43.     exit(1);
  44.   }
  45.   if ((got = glutGet(GLUT_INIT_WINDOW_HEIGHT)) != 400) {
  46.     printf("FAIL: width height, got %d, not 400\n", got);
  47.     exit(1);
  48.   }
  49.   screen_width = glutGet(GLUT_SCREEN_WIDTH);
  50.   screen_height = glutGet(GLUT_SCREEN_HEIGHT);
  51.   if ((got = glutGet(GLUT_INIT_WINDOW_X)) != (screen_width - 500 - 34)) {
  52.     printf("FAIL: width x, got %d, not %d\n", got, screen_width - 500 - 34);
  53.     exit(1);
  54.   }
  55.   if ((got = glutGet(GLUT_INIT_WINDOW_Y)) != (screen_height - 400 - 23)) {
  56.     printf("FAIL: width y, got %d, not %d\n", got, screen_height - 400 - 23);
  57.     exit(1);
  58.   }
  59.   if (glutGet(GLUT_INIT_DISPLAY_MODE) !=
  60.     (GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH)) {
  61.     printf("FAIL: width wrong\n");
  62.     exit(1);
  63.   }
  64.   glutInitWindowPosition(10, 10);
  65.   glutInitWindowSize(200, 200);
  66.   glutInitDisplayMode(
  67.     GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
  68.   if (glutGet(GLUT_INIT_WINDOW_WIDTH) != 200) {
  69.     printf("FAIL: width wrong\n");
  70.     exit(1);
  71.   }
  72.   if (glutGet(GLUT_INIT_WINDOW_HEIGHT) != 200) {
  73.     printf("FAIL: width wrong\n");
  74.     exit(1);
  75.   }
  76.   if (glutGet(GLUT_INIT_WINDOW_X) != 10) {
  77.     printf("FAIL: width wrong\n");
  78.     exit(1);
  79.   }
  80.   if (glutGet(GLUT_INIT_WINDOW_Y) != 10) {
  81.     printf("FAIL: width wrong\n");
  82.     exit(1);
  83.   }
  84.   if (glutGet(GLUT_INIT_DISPLAY_MODE) !=
  85.     (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL)) {
  86.     printf("FAIL: width wrong\n");
  87.     exit(1);
  88.   }
  89.   printf("PASS: test1\n");
  90.   return 0;             /* ANSI C requires main to return int. */
  91. }
  92.